package org.activequant.util.ib;

import com.ib.client.Contract;
import com.ib.client.Execution;
import com.ib.client.Order;
import com.ib.client.OrderState;

/**
 * 
 * An Interface for an event listener.<br/>
 * Defines the following methods:
 * <ul>
 * <li>public void execDetails(int orderId, Contract arg1, Execution arg2);</li>
 * <li>public void orderStatus(int orderId, String arg1, int arg2, int arg3, double arg4, int arg5, int arg6, double arg7, int arg8);</li>
 * <li>public void updatePortfolio(Contract instrument, int positionCount, double marketPrice, double marketValue, double avgCost, double unrealizedPNL, double realizedPNL, String accountName);</li>
 * <li>public void updateAccountValue(String informationType, String amount, String currency, String account);</li>
 * <li>public void error(int orderId, int errorCode, String message);</li>
 * <li>public void openOrder(int orderId, Contract contract, Order order);</li>
 * </ul>
 * <br>
 * <b>History:</b><br>
 *  - [05.07.2007] Created (Ulrich Staudinger)<br>
 *
 *  @author Ulrich Staudinger
 */
public interface IBEventListener {
	
	/**
	 * execution details are routed through this. 
	 * @param reqId
	 * @param arg1
	 * @param arg2
	 */
	public void execDetails(int reqId, Contract arg1, Execution arg2);
	/**
	 * this method gets called after (possibly multiple) call to execDetails
	 * @param reqId
	 */
	public void execDetailsEnd(int reqId);
	/**
	 * the order status arrives through this method.
	 * @param orderId
	 * @param status
	 * @param filled
	 * @param remaining
	 * @param avgFillPrice
	 * @param permId
	 * @param parentId
	 * @param lastFillPrice
	 * @param clientId
	 * @param whyHeld
	 */
	public void orderStatus(int orderId, String status, int filled, int remaining, double avgFillPrice, int permId, int parentId, double lastFillPrice, int clientId, String whyHeld);

	/**
	 * portfolio position come in through this
	 * @param contract
	 * @param positionCount
	 * @param marketPrice
	 * @param marketValue
	 * @param avgCost
	 * @param unrealizedPNL
	 * @param realizedPNL
	 * @param accountName
	 */
	public void updatePortfolio(Contract instrument, int positionCount, double marketPrice, double marketValue, double avgCost, double unrealizedPNL, double realizedPNL, String accountName);
	
	
	/**
	 * account value. 
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @param arg3
	 */
	public void updateAccountValue(String informationType, String amount, String currency, String account);

	
	public void error(int orderId, int errorCode, String message);

	public void openOrder(int orderId, Contract contract, Order order, OrderState orderState);
}
